//
//  NSParagraphStyle.h
//  UIKit
//
//  Copyright (c) 2011-2014 Apple Inc. All rights reserved.
//
// NSParagraphStyle and NSMutableParagraphStyle hold paragraph style information
// 

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKitDefines.h>
#import <UIKit/NSText.h>


// NSTextTab
UIKIT_EXTERN NSString *const NSTabColumnTerminatorsAttributeName NS_AVAILABLE_IOS(7_0); /* An attribute for NSTextTab options.  The value is NSCharacterSet.  The character set is used to determine the tab column terminating character.  The tab and newline characters are implied even if not included in the character set. */

NS_CLASS_AVAILABLE_IOS(7_0) @interface NSTextTab : NSObject <NSCopying, NSCoding>
- (instancetype)initWithTextAlignment:(NSTextAlignment)alignment location:(CGFloat)loc options:(NSDictionary *)options; /* Initializes a text tab with the text alignment, location, and options.  The text alignment is used to determine the position of text inside the tab column. */

+ (NSCharacterSet *)columnTerminatorsForLocale:(NSLocale *)aLocale; // Returns the column terminators for locale. Passing nil returns an instance corresponding to the system locale. For matching user's formatting preferences, pass [NSLocale currentLocale]. Can be used as the value for NSTabColumnTerminatorsAttributeName to make a decimal tab stop */

@property(readonly) NSTextAlignment alignment;  /* Defines the aligment of tab column contents. NSTextAlignmentNatural and NSTextAlignmentJustified are resolved either NSTextAlignmentLeft or NSTextAlignmentRight based on the user's preferred language */
@property(readonly) CGFloat location; /* Location of the tab stop inside the line fragment rect coordinate system */
@property(readonly) NSDictionary *options; /* Optional configuration attributes */
@end


// NSParagraphStyle
typedef NS_ENUM(NSInteger, NSLineBreakMode) {		/* What to do with long lines */
    NSLineBreakByWordWrapping = 0,     	/* Wrap at word boundaries, default */
    NSLineBreakByCharWrapping,		/* Wrap at character boundaries */
    NSLineBreakByClipping,		/* Simply clip */
    NSLineBreakByTruncatingHead,	/* Truncate at head of line: "...wxyz" */
    NSLineBreakByTruncatingTail,	/* Truncate at tail of line: "abcd..." */
    NSLineBreakByTruncatingMiddle	/* Truncate middle of line:  "ab...yz" */
} NS_ENUM_AVAILABLE_IOS(6_0);

NS_CLASS_AVAILABLE_IOS(6_0) @interface NSParagraphStyle : NSObject <NSCopying, NSMutableCopying, NSCoding> 

+ (NSParagraphStyle *)defaultParagraphStyle;

+ (NSWritingDirection)defaultWritingDirectionForLanguage:(NSString *)languageName;  // languageName is in ISO lang region format

@property(readonly) CGFloat lineSpacing; /* "Leading": distance between the bottom of one line fragment and top of next (applied between lines in the same container). This value is included in the line fragment heights in layout manager. */
@property(readonly) CGFloat paragraphSpacing; /* Distance between the bottom of this paragraph and top of next (or the beginning of its paragraphSpacingBefore, if any). */
@property(readonly) NSTextAlignment alignment;

/* The following values are relative to the appropriate margin (depending on the paragraph direction) */

@property(readonly) CGFloat headIndent; /* Distance from margin to front edge of paragraph */
@property(readonly) CGFloat tailIndent; /* Distance from margin to back edge of paragraph; if negative or 0, from other margin */
@property(readonly) CGFloat firstLineHeadIndent; /* Distance from margin to edge appropriate for text direction */

@property(readonly) CGFloat minimumLineHeight; /* Line height is the distance from bottom of descenders to top of ascenders; basically the line fragment height. Does not include lineSpacing (which is added after this computation). */
@property(readonly) CGFloat maximumLineHeight; /* 0 implies no maximum. */ 

@property(readonly) NSLineBreakMode lineBreakMode;

@property(readonly) NSWritingDirection baseWritingDirection;

@property(readonly) CGFloat lineHeightMultiple; /* Natural line height is multiplied by this factor (if positive) before being constrained by minimum and maximum line height. */
@property(readonly) CGFloat paragraphSpacingBefore; /* Distance between the bottom of the previous paragraph (or the end of its paragraphSpacing, if any) and the top of this paragraph. */

/* Specifies the threshold for hyphenation.  Valid values lie between 0.0 and 1.0 inclusive.  Hyphenation will be attempted when the ratio of the text width as broken without hyphenation to the width of the line fragment is less than the hyphenation factor.  When this takes on its default value of 0.0, the layout manager's hyphenation factor is used instead.  When both are 0.0, hyphenation is disabled.
 
    NOTE: On iOS, the only supported values are 0.0 and 1.0.
*/
@property(readonly) float hyphenationFactor;

@property(readonly,copy,NS_NONATOMIC_IOSONLY) NSArray *tabStops NS_AVAILABLE_IOS(7_0); // An array of NSTextTabs. Default value is nil. Contents should be ordered by localtion
@property(readonly,NS_NONATOMIC_IOSONLY) CGFloat defaultTabInterval NS_AVAILABLE_IOS(7_0); // The default tab interval used for locations beyond the last element in tabStops
@end


NS_CLASS_AVAILABLE_IOS(6_0) @interface NSMutableParagraphStyle : NSParagraphStyle

@property(readwrite) CGFloat lineSpacing;
@property(readwrite) CGFloat paragraphSpacing;
@property(readwrite) NSTextAlignment alignment;
@property(readwrite) CGFloat firstLineHeadIndent;
@property(readwrite) CGFloat headIndent;
@property(readwrite) CGFloat tailIndent;
@property(readwrite) NSLineBreakMode lineBreakMode;
@property(readwrite) CGFloat minimumLineHeight;
@property(readwrite) CGFloat maximumLineHeight;
@property(readwrite) NSWritingDirection baseWritingDirection;
@property(readwrite) CGFloat lineHeightMultiple;
@property(readwrite) CGFloat paragraphSpacingBefore;
@property(readwrite) float hyphenationFactor;
@property(readwrite,copy,NS_NONATOMIC_IOSONLY) NSArray *tabStops NS_AVAILABLE_IOS(7_0);
@property(readwrite,NS_NONATOMIC_IOSONLY) CGFloat defaultTabInterval NS_AVAILABLE_IOS(7_0);

@end
